<template>
  <div class="user-page">
    <div class="header">
      <van-image round class="avatar" :src="userInfo.avatar" />
      <h3 class="user-name">{{userInfo.username}}</h3>
    </div>
    <div class="nav-box">
      <van-grid :column-num="3">
        <van-grid-item icon="clock-o" text="历史记录" />
        <van-grid-item icon="goods-collect-o" text="我的收藏" />
        <van-grid-item icon="thumb-circle-o" text="我的点赞" />
      </van-grid>
    </div>
    <div>
      <van-cell title="推荐分享" is-link />
      <van-cell title="意见反馈" is-link />
      <van-cell title="关于我们" is-link />
      <van-cell title="退出登录" is-link @click="outFn" />
    </div>
  </div>
</template>

<script>
import { del } from '@/utils/storage'
import { getUserInfo } from '@/api/user'
export default {
  name: 'user-page',
  props: {},
  components: {},
  data () {
    return {
      userInfo: {}
    }
  },
  computed: {},
  watch: {},
  created () {
    this.getUserInfo()
  },
  methods: {
    async getUserInfo () {
      const { data } = await getUserInfo()
      console.log(data)
      this.userInfo = data.data
    },
    outFn () {
      del()
      this.$router.push('/login')
    }
  }
}
</script>

<style lang="less" scoped>
.user-page {
  padding: 0 10px;
}
.header {
  display: flex;
  align-items: center;
  padding: 20px 0;
  .avatar {
    width: 90px;
    height: 90px;
  }
  .user-name {
    padding: 20px;
  }
}
.nav-box {
  margin-bottom: 20px;
}
</style>
